package com.gitee.wsl.data.recycler


/**
 * [RecyclerPool] implementation that uses
 * a bounded queue ([ArrayBlockingQueue] for recycling instances.
 * This is "bounded" pool since it will never hold on to more
 * pooled instances than its size configuration:
 * the default size is [BoundedPoolBase.DEFAULT_CAPACITY].
 */
//    abstract class BoundedPoolBase<P : WithPool<P>>
//    protected constructor(capacityAsId: Int) : StatefulImplBase<P>(capacityAsId) {
//        @Transient
//        private val pool: ArrayBlockingQueue<P>
//
//        @Transient
//        private val capacity: Int = if (capacityAsId <= 0) DEFAULT_CAPACITY else capacityAsId
//
//        // // // Life-cycle (constructors, factory methods)
//        init {
//            pool = ArrayBlockingQueue(capacity)
//        }
//
//        // // // Actual API implementation
//        override fun acquirePooled(): P {
//            var pooled = pool.poll()
//            if (pooled == null) {
//                pooled = createPooled()
//            }
//            return pooled
//        }
//
//        override fun releasePooled(pooled: P) {
//            pool.offer(pooled)
//        }
//
//        override fun pooledCount(): Int {
//            return pool.size
//        }
//
//        override fun clear(): Boolean {
//            pool.clear()
//            return true
//        }
//
//        // // // Other methods
//        fun capacity(): Int {
//            return capacity
//        }
//
//        companion object {
//
//            /**
//             * Default capacity which limits number of items that are ever
//             * retained for reuse.
//             */
//            const val DEFAULT_CAPACITY: Int = 100
//        }
//    }